package com.zx.webflux.controller;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
 * <p>
 * description:  <br>
 * create: 2024-08-16 21:05
 * </p>
 *
 * @author zhou  xun
 */
@RestController
public class ReactiveController {


    @GetMapping(value = "/hello", produces = MediaType.TEXT_PLAIN_VALUE)
    @ResponseBody
    public Mono<String> helloMono() {
        return Mono.just("Hello, Mono!");
    }


    @GetMapping(value = "/greetings", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    @ResponseBody
    public Flux<String> streamGreetings() {
        return Flux.just("Hello", "World", "from", "WebFlux");
    }
}